package 集合.日常使用;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Description
 *
 * @Author: SunAo
 * @Date: 2022/3/29 18:11
 */
public class Collectors_joining方法 {

    @Test
    public void 逗号分隔(){
        List<String> array = Arrays.asList("你好", "你是谁");
        String result = array.stream().collect(Collectors.joining(","));
        System.out.println(result);
    }

    @Test
    public void 单个元素(){
        List<String> array = Arrays.asList("你好");
        String result = array.stream().collect(Collectors.joining(","));
        System.out.println(result);
    }
}
